package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.entity.AlertRule;
import com.zzyl.service.AlertDataService;
import com.zzyl.vo.AlertDataVo;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description AlertData
 * @Author KangChi Wang
 * @Date 2024-09-15
 */
@RestController
@Slf4j
@RequestMapping("/alert-data")
public class AlertDataController {
    @Autowired
    private AlertDataService alertDataService;

    @ApiOperation("分页查询报警数据")
    @GetMapping("pageQuery")
    public ResponseResult<PageResponse<AlertDataVo>> pageQuery(Integer pageNum,
                                                               Integer pageSize,
                                                               String deviceName,
                                                               Integer endTime,
                                                               Integer startTime,
                                                               Integer status,
                                                               Integer id
    ) {
        PageResponse<AlertDataVo> pages = alertDataService.pageQuery(pageNum, pageSize, deviceName, endTime, startTime, status, id);
        return ResponseResult.success(pages);
    }
    @ApiOperation("处理设备报警数据")
    @PutMapping("/handleAlertData/{id}")
    public ResponseResult handleAlertData(@PathVariable Long id, @RequestBody AlertDataVo alertDataVo) {
        alertDataService.handleAlertData(id, alertDataVo);
        return ResponseResult.success();
    }
}
